<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of MenuConstants
 *
 * @author sebastien
 */
class menu
{

    const HOME                      = 'home';

    const TOURNAMENT                = 'tournament';
    const TOURNAMENT__FIND          = 'tournament_find';
    const TOURNAMENT__NEWTOURNAMENT = 'tournament_newtournament';
    const TOURNAMENT__MYTOURNAMENT  = 'tournament_mytournament';

    const CLUB                      = 'club';
    const CLUB__FIND                = 'club_find';
    const CLUB__MYCLUB              = 'club_myclub';
    const CLUB__NEWCLUB             = 'club_newclub';

    const REFEREE                   = 'referee';

    const CAOCH                     = 'coach';

    const SETTINGS                  = 'settings';
    const NONE                      = '';

    public static function subMenuEntrytoString($subMenuEntryConst) {
        switch ($subMenuEntryConst){
            case menu::CLUB__FIND: return 'Find a club';
            case menu::CLUB__MYCLUB: return 'My club';
            case menu::CLUB__NEWCLUB: return 'New club';

            case menu::TOURNAMENT__FIND: return 'Find a tournament';
            case menu::TOURNAMENT__MYTOURNAMENT: return 'My tournaments';
            case menu::TOURNAMENT__NEWTOURNAMENT: return 'New tournament';
            default: return null;
        }
    }

    public $menu_entry;
    public $submenu_entry;
    
    public function __construct($init_menu_entry) {
        $this->menu_entry = $init_menu_entry;
    }
    public function setMenuEntry($menuName = null, $submenuName = null) {
        $this->menu_entry = $menuName;
        $this->submenu_entry = $submenuName;
    }

    public function getStyles($menuName) {
        if ($this->menu_entry == $menuName) {
            return 'menu_entry menu_selected' ;
        } else {
            return 'menu_entry menu_unselected';
        }
    }
    public function __toString() {
        return 'menu(selectedEntry('.$this->menu_entry
                .'),  selectedSubEntry('.$this->submenu_entry
                .'))';
    }
    public function getSubMenuEntries($sf_user) {
        $person = $sf_user->getPerson();
        switch ($this->menu_entry) {
            case menu::CLUB:
                if ($person == null) {
                    return array(menu::CLUB__FIND);

                } else if ($person->hasAClub()) {
                    return array(menu::CLUB__MYCLUB,menu::CLUB__FIND);
                    
                } else {
                    return array(menu::CLUB__NEWCLUB,menu::CLUB__FIND);
                }

            case menu::TOURNAMENT:
                if ($person == null) {
                    return array(menu::TOURNAMENT__FIND);
                } else {
                    return array(menu::TOURNAMENT__MYTOURNAMENT, menu::TOURNAMENT__FIND);
                }
                
            default:
                return null;
        }
    }
    public function getSubMenuStyles($subMenuName) {
        if ($this->submenu_entry == $subMenuName) {
            return 'selected' ;
        } else {
            return '';
        }
    }
}
?>
